﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Web.UI;

namespace AiXiu.WebSite
{
    public partial class Mobile : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if(Page.IsValid)
            {
                string mobile = txtMobileNumber.Text;
                string password = txtPassword.Text;
                IUserManager userManager = new UserManager();
                OperResult<TBUsers> operResult = userManager.LoginByMobile(mobile, password);
                if (operResult.StatusCode == StatusCode.Succeed)
                {
                    //缓存用户资料
                    TBUsers user = operResult.ReadResult();
                    IdentityManager.SaveUser(user);

                    //forms身份认证，返回路径直接跳转

                    this.Redirect("loginsuccess", "Default.aspx");

                }
                else
                {
                    this.Alert("lgnfail", operResult.Message ?? "操作失败！");
                }
            }
        }
    }
}